﻿<?xml version="1.0" encoding="utf-8" ?>
<!--namespace必须用否者就报错（读取配置文件报：未将对象引用设置到对象的实例）-->
<sqlMap namespace="" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <statements>
    <insert id="AdvertSpace.Insert" parameterClass="hashtable">
      INSERT INTO [AdvertSpace]
      (
      [Id]
      ,[Code]
      ,[Title]
      ,[Template]
      ,[Remark]
      ,[IsValid]
      )
      VALUES
      (
      #Id#
      ,#Code#
      ,#Title#
      ,#Template#
      ,#Remark#
      ,#IsValid#
      )
    </insert>

    <update id="AdvertSpace.Update" parameterClass="hashtable" resultClass="int">
      UPDATE [AdvertSpace]
      SET
      [Id] =#Id#
      ,[Code] =#Code#
      ,[Title] =#Title#
      ,[Template] =#Template#
      ,[Remark] =#Remark#
      ,[IsValid] =#IsValid#

      WHERE  [Id] =#Id#
    </update>

    <select id="AdvertSpace.Get" parameterClass="string" resultClass="Kaiser.Modules.Cubic.DomainModel.Advert.AdvertSpace">
      select
      [Id]
      ,[Code]
      ,[Title]
      ,[Template]
      ,[Remark]
      ,[IsValid]
      from AdvertSpace
      where [Id]='$Id$'
    </select>

    <select id="AdvertSpace.Search" parameterClass="Kaiser.Modules.Cubic.ViewModel.AdvertSpaceSearch" resultClass="HashTable">
      select
      [Id]
      ,[Code]
      ,[Title]
      ,[Template]
      ,[Remark]
      ,[IsValid]
      from AdvertSpace
      <dynamic prepend="where">
        <isParameterPresent>
          <isNotEmpty prepend="and" property="Title">
            [Title] like '%$Title$%'
          </isNotEmpty>
          <isNotEmpty prepend="and" property="Code">
            [Code] like '%$Code$%'
          </isNotEmpty>
        </isParameterPresent>
      </dynamic>
    </select>

    <select id="AdvertSpace.GetByCode" parameterClass="string" resultClass="Kaiser.Modules.Cubic.DomainModel.Advert.AdvertSpace">
      select
      [Id]
      ,[Code]
      ,[Title]
      ,[Template]
      ,[Remark]
      ,[IsValid]
      from AdvertSpace
      where [Code]=#value#
    </select>

    <delete id="AdvertSpace.DeleteList" parameterClass="string" resultClass="int">
      delete  [AdvertSpace] where [Id] in
      <iterate    open="(" close=")"  conjunction=",">
        #[]#
      </iterate>
    </delete>

  </statements>
</sqlMap>

